package com.thread;

import java.util.concurrent.CountDownLatch;

/**
 * Created with IntelliJ IDEA.
 * User: 5
 * Date: 16-12-8
 * Time: 上午9:55
 * To change this template use File | Settings | File Templates.
 */
public class MyCountDownLatch implements Runnable {
    private CountDownLatch countDownLatch;
    public int count = 0;
    static int name = 5;

    static {
        System.out.println(name);
    }


    public MyCountDownLatch(CountDownLatch latch) {
        this.countDownLatch = latch;
    }


    public MyCountDownLatch() {


    }

    @Override
    public void run() {
        while (count < 50) {
            countPlusPlus();
        }
        countDownLatch.countDown();
    }

    public void countPlusPlus() {
        synchronized (this) {
//            System.out.println(Thread.currentThread().getName() + "----  count:" + count);
            count++;
        }
    }


}
